(function(YuXi){
	var util={};
	
	var loginUrl="http://"+window.location.host+"/yuxi/login.jsp";	
	util.get=function(url,data,callbacksuccess,callbackerror){		
		var base="/yuxi/LoginFilter/";	
		YuXi.loadding.show();
		var baseSuccessFn=function(data){
			YuXi.loadding.hide();		
			if((!data.status)&&data.errorCode=="20001"){
				window.location.href=loginUrl;
				return false;
			}
			callbacksuccess(data);
		};
		var baseErrorFn=function(){	
			YuXi.loadding.hide();			
			callbackerror(data);
		};
		$.ajax({
			  type: "GET",
			  url: base+url,
			  data:data,
			  cache:false,
			  dataType: "json",
			  success:baseSuccessFn,
			  error:baseErrorFn
			});
	
	}

	util.getAsync=function(url,data,callbacksuccess,callbackerror){		
		var base="/yuxi/LoginFilter/";	
		//YuXi.loadding.show();
		var baseSuccessFn=function(data){
			YuXi.loadding.hide();		
			if((!data.status)&&data.errorCode=="20001"){
				window.location.href=loginUrl;
				return false;
			}
			callbacksuccess(data);
		};
		var baseErrorFn=function(){	
			//YuXi.loadding.hide();			
			callbackerror(data);
		};
		$.ajax({
			  type: "GET",
			  url: base+url,
			  data:data,
			  async:false,
			  cache:false,
			  dataType: "json",
			  success:baseSuccessFn,
			  error:baseErrorFn
			});
	
	}

	util.getAsynCache=function(url,data,callbacksuccess,callbackerror){		
		var base="/yuxi/LoginFilter/";	
		//YuXi.loadding.show();
		var baseSuccessFn=function(data){
			//YuXi.loadding.hide();		
			if((!data.status)&&data.errorCode=="20001"){
				window.location.href=loginUrl;
				return false;
			}
			callbacksuccess(data);
		};
		var baseErrorFn=function(){	
			//YuXi.loadding.hide();			
			callbackerror(data);
		};
		$.ajax({
			  type: "GET",
			  url: base+url,
			  data:data,
			  async:false,
			  cache:true,
			  dataType: "json",
			  success:baseSuccessFn,
			  error:baseErrorFn
			});
	
	}
	
	util.post=function(url,data,callbacksuccess,callbackerror){
		var base="/yuxi/LoginFilter/";	
		YuXi.loadding.show();
		var baseErrorFn=function(){	
			YuXi.loadding.hide();			
			callbackerror(data);
		};
		var baseSuccessFn=function(data){	
			YuXi.loadding.hide();
			if((!data.status)&&data.errorCode=="20001"){
				window.location.href=loginUrl;
				return false;
			}else{
				if((!data.status)&&data.errorCode=="30001"){
					myTool.alert({
						title:"提示",
						context:"你无此模块权限"
					});					
				return false;
				}
			}
			callbacksuccess(data);
		};
		
		$.ajax({
			  type: "POST",
			  url: base+url,
			  data:data,
			  cache:false,
			  dataType: "json",
			  success:baseSuccessFn,
			  error:baseErrorFn
			});
	
	}
	
	function openwin(url) {
	    var a = document.createElement("a");
	    a.setAttribute("href", url);
	    a.setAttribute("target", "_blank");
	    a.setAttribute("id", "openwin");
	    document.body.appendChild(a);
	    a.click();
	}
	
	YuXi.util=util;
})(window.YuXi)
